#ifndef VECTOR3_H
#define VECTOR3_H
#include <QVector3D>
#include <QStringList>

class Vector3 : public QVector3D {
public:
    /**
     * @brief 构造函数
     */
    Vector3(): QVector3D() {}

    /**
     * @brief 构造函数
     * @param x
     * @param y
     * @param z
     */
    Vector3(float x, float y, float z): QVector3D(x, y, z) {}

    /**
     * @brief operator =
     * @param value
     * @return
     */
    Vector3& operator = (const QVector3D& value) {
        setX(value.x());
        setY(value.y());
        setZ(value.z());
        return *this;
    }

    /**
     * @brief 解析字符串
     * @param value
     */
    void Parse(const QString& value)
    {
        QStringList val = value.split(',');
        if (val.length() != 3) return;
        setX(val[0].toFloat());
        setY(val[1].toFloat());
        setZ(val[2].toFloat());
    }

    /**
     * @brief 重载 ToString
     * @return
     */
    QString ToString() const
    {
        return QString("%1,%2,%3").arg(x()).arg(y()).arg(z());
    }
};

#endif // VECTOR3_H
